package com.yunxi.service.dubboService.impl.vehicle;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.codingapi.txlcn.tc.annotation.TxTransaction;
import com.github.pagehelper.PageInfo;
import com.yunxi.model.vehicle.VehicleConfigVer;
import com.yunxi.model.vehicle.VehiclePackageCustomer;
import com.yunxi.service.localService.vehicle.VehiclePackageService;
import com.yunxi.vehicle.pojo.VehiclePackageConfigForAppRespVO;
import com.yunxi.vehicle.pojo.VehiclePackageForAppReqVO;
import com.yunxi.vehicle.pojo.VehiclePackageForAppRespVO;
import com.yunxi.vehicle.pojo.VehiclePackageRespVO;
import com.yunxi.vehicle.service.VehiclePackageDubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2019-05-22
 */
/*@com.alibaba.dubbo.config.annotation.Service(version = "${demo.service.version}",
        application = "${dubbo.application.id}",
        protocol = "${dubbo.protocol.id}",
        registry = "${dubbo.registry.id}"
)*/
public class VehiclePackageDubboServiceImpl implements VehiclePackageDubboService {

    @Autowired
    @Qualifier(value = "vehiclePackageServiceImpl")
    VehiclePackageService vehiclePackageServiceImpl;

    /**
     * 选装包下拉列表查询
     * @return
     */
    @Override
    @Transactional
    public List<VehiclePackageRespVO> queryVehiclePackage(String productCode){
        List<VehiclePackageCustomer> vehiclePackageCustomers =  vehiclePackageServiceImpl.queryVehiclePackage(productCode);
        List<VehiclePackageRespVO> voList = new ArrayList<>();
        for(int i = 0; i < vehiclePackageCustomers.size(); i ++){
            VehiclePackageRespVO vo = new VehiclePackageRespVO();
            BeanUtils.copyProperties(vehiclePackageCustomers.get(i),vo);
            voList.add(vo);
        }
        return voList;
     }



    @Override
    public List<VehiclePackageForAppRespVO> queryVehiclePackageByApp(VehiclePackageForAppReqVO vo) {
        return vehiclePackageServiceImpl.queryVehiclePackageByApp(vo);
    }

    @Override
    public List<VehiclePackageForAppRespVO> queryVehiclePackageByAppLast(VehiclePackageForAppReqVO vo) {
        return vehiclePackageServiceImpl.queryVehiclePackageByAppLast(vo);
    }

    @Override
    @Transactional
    @LcnTransaction
    public List<VehiclePackageForAppRespVO>  queryTest(){
        return vehiclePackageServiceImpl.queryTest();
    }

    @Override
    public String strByNodeCodeIn(String customSqlStr) {
        return vehiclePackageServiceImpl.strByNodeCodeIn(customSqlStr);
    }

    @Override
    @Transactional
    public PageInfo<VehiclePackageConfigForAppRespVO> queryVehiclePackageConfigByApp(int pageNum, int pageSize){
        return vehiclePackageServiceImpl.queryVehiclePackageConfigByApp(pageNum,pageSize);
    }
}
